﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace CustomControls.MessageBox
{
    /// <summary>
    /// NotifyMessage.xaml 的交互逻辑
    /// </summary>
    public partial class NotifyMessage : System.Windows.Controls.Canvas
    {
        public NotifyMessageViewModle Context { get { return this.DataContext as NotifyMessageViewModle; } }
        public NotifyMessage(string content)
        {
            InitializeComponent();
            MessageInfo.Text = content;
            MessageBoxResult = System.Windows.MessageBoxResult.None;
            this.DataContext = new NotifyMessageViewModle();
        }


        /// <summary>
        /// 消息框按钮返回值
        /// </summary>
        public MessageBoxResult MessageBoxResult
        {
            get;
            set;
        }


        /// <summary>
        /// 设置消息框中显示的图标样式
        /// </summary>
        /// <param name="msgImage">图标样式类型</param>
        /// <param name="win">弹出窗口对象</param>
        /// <returns></returns>
        public void SetMessageImageStyle(MessageBoxImage msgImage, UserControl win)
        {
            Style retValue = null;
            switch (msgImage)//选择图片状态
            {
                case MessageBoxImage.Warning:
                    retValue = win.TryFindResource("Common_Bmp_mMessageBoxWarning") as System.Windows.Style;
                    break;
                case MessageBoxImage.Error:
                    retValue = win.TryFindResource("Common_Bmp_mMessageBoxError") as System.Windows.Style;
                    break;
                case MessageBoxImage.Question:
                    retValue = win.TryFindResource("Common_Bmp_mMessageBoxQuestion") as System.Windows.Style;
                    break;
                case MessageBoxImage.Information:
                    retValue = win.TryFindResource("Common_Bmp_mMessageBoxInformation") as System.Windows.Style;
                    break;
            }
            this.MessageboxImagebg.Style = retValue;
        }

        private void ResetTest_Click(object sender, RoutedEventArgs e)
        {
            this.popupId.IsOpen = false;
            this.CanvasContainerId.Visibility = Visibility.Collapsed;
            MessageBoxResult = System.Windows.MessageBoxResult.None;
        }

        private void IgnorTest_Click(object sender, RoutedEventArgs e)
        {
            this.popupId.IsOpen = false;
            this.CanvasContainerId.Visibility = Visibility.Collapsed;
            MessageBoxResult = System.Windows.MessageBoxResult.None;
        }
    }
}
